/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 castle_gate.h

	$Header: /heroes4/castle_gate.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( CASTLE_GATE_H_INCLUDED )
#define CASTLE_GATE_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "attackable_obstacle.h"

class t_town;
enum  t_town_image_level;
enum  t_town_type;

enum t_gate_animation
{
	k_gate_animation_none,
	k_gate_animation_open,
	k_gate_animation_close,
	k_gate_animation_destroy,
};

// --------------------------------------------------------------
// castle gate object
// --------------------------------------------------------------
class t_castle_gate : public t_attackable_obstacle
{
public:
	t_castle_gate( t_battlefield& battlefield );
	virtual ~t_castle_gate();
	t_castle_gate( t_battlefield& battlefield, 
		           t_combat_object_model_cache const& model_cache, t_town const* town );

	virtual void					apply_damage( t_battlefield& battlefield, bool show_death );
	virtual bool					belongs_to( bool defender ) const;
	virtual bool					controlled_by( bool defender ) const;
	virtual void					flinch( t_combat_creature const& attacker, 
											t_combat_action_message const & message );
	virtual std::string				get_object_name() const;
	virtual t_combat_object_type	get_object_type() const;
	t_map_rect_2d					get_open_rect() const;
	t_map_point_2d					get_position() const;
	virtual bool					is_gate() const;
	bool							is_open() const;
	virtual void					on_idle();
	virtual void					place( t_battlefield& battlefield, t_map_point_2d const& point );
	virtual bool					read( t_combat_reader& reader );
	virtual void					remove( t_battlefield& battlefield );
	void							start_animation( t_battlefield&		battlefield,
													 t_gate_animation	animation,
													 t_handler			end_handler );
	virtual bool					write( t_combat_writer& writer ) const;
protected:
	void change_model( t_combat_object_model_cache const& model );

	t_gate_animation	m_animation;
	t_battlefield&		m_battlefield;
	t_town_image_level	m_castle_level;
	t_handler			m_end_handler;
	t_map_point_2d		m_position;
	t_town_type			m_town_type;
};


inline t_map_point_2d t_castle_gate::get_position() const
{
	return m_position;
}

#endif // CASTLE_GATE_H_INCLUDED